﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cstudy.BLL;

public partial class admin_artcles_list : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetList();
            if (Request.QueryString["act"] == "del")
            {
                if (new Cstudy.BLL.Artcles().DeleteArtcleByID(int.Parse(Request.QueryString["id"])))
                {
                    scriptmsg.Text = "<script>alert('删除成功');</script>";
                }
                else
                {
                    scriptmsg.Text = "<script>alert('删除失败');</script>";
                }
                Response.Redirect("list.aspx");
            }
        }

    }

    private void GetList()
    {
        int num;
        DataSet ds = new Cstudy.BLL.Artcles().SelectArtcle(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out num, "@count");
        AspNetPager1.RecordCount = num;
        if (ds != null)
        {
            ArtcleListBox.DataSource = ds.Tables[0].DefaultView;
            ArtcleListBox.DataBind();
        }
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        GetList();
    }
}